
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
from typing import Optional,List

from pydantic import BaseModel, Field, EmailStr


class StationInfo(BaseModel):
    station:str
    sleep_time:int


class RSTask(BaseModel):
    id: int = Field(..., example='id')
    # user_id:Mapped[int] = mapped_column(ForeignKey('user_table.id'),nullable=False,comment='所属用户的id')
    name: str = Field(..., example='task的自定义名称')
    task_name: str = Field(..., example='task的唯一名称')
    task_list:  List[StationInfo]=Field(..., example='站点信息和每个站点停留的时间')



class RQRunTask(BaseModel):
    task_name:str
    is_loop:bool = Field(False)
    
    class Config:
        schema_extra = {
            "example": {
                "task_name": "任务链唯一名称",
                "is_loop":False
            }
        }


class RQUpdateTask(BaseModel):
    id:int
    name:str
    
    class Config:
        schema_extra = {
            "example": {
                "id": 0,
                "name": "任务链的自己起的名称"
            }
        }





class RQTask(BaseModel):
    name:str 
    task_list:List[StationInfo]
    is_save:bool = Field(True)
    is_run:bool=Field(False)
    is_loop:bool=Field(False)

    class Config:
        schema_extra = {
            "example": {
                "name": "充电任务链",
                "task_list":[
                    {
                        "station": "LM201",
                        "sleep_time": 0
                    },
                    {
                        "station": "LM200",
                        "sleep_time": 0
                    }
                ],
                "is_save": True,
                "is_run":False,
                "is_loop":False
            }
        }


class RQTaskSleepTime(BaseModel):
    id:int
    task_name:str
    name:str 
    task_list:List[StationInfo]

    class Config:
        schema_extra = {
            "example": {
                "name": "充电任务链",
                "task_name":"自定义名称",
                "task_list":[
                    {
                        "station": "LM201",
                        "sleep_time": 0
                    },
                    {
                        "station": "LM200",
                        "sleep_time": 0
                    }
                ],

            }
        }


class DAOCreateTask(BaseModel):
    name:str 
    task_name:str

    

    



class CreateProjectTimer(BaseModel):
    """_创建用户工时计时的项目,不一定是专案_

    Args:
        BaseModel (_type_): _description_
    """
    loginid: str = Field(..., example='用户的loginid不需要用户手动填写')
    # user_id:Mapped[int] = mapped_column(ForeignKey('user_table.id'),nullable=False,comment='所属用户的id')
    name: str = Field(..., example='项目的名称')
    type: str = Field(..., example='项目类别')
    plan_time:int = Field(..., example=100)
    introduction: Optional[str] = Field(..., example='项目的额外说明(可以没有)')




    """_开始工时计时_

    Args:
        BaseModel (_type_): _description_
    """
    project_id:int= Field(..., example='项目的id')






    
class CreateProjectTimerDao(BaseModel):
    """_创建用户工时计时的项目,Dao层_

    Args:
        BaseModel (_type_): _description_
    """
    user_id:int
    name: str 
    type: str 
    plan_time:int
    introduction: Optional[str] 





class ProjectWithUserInfo(BaseModel):
    """返回的项目信息

    Args:
        BaseModel (_type_): 返回的信息除了项目的基本信息,还要有一些用户的信息 
    """
    id: str = None
    user_id: int = None
    name: str = None
    type: str = None
    progress: float = None
    acc_time: int = None
    plan_time: int = None
    introduction: Optional[str] = None
    create_time: datetime.datetime = None
    update_time: Optional[datetime.datetime] = None

    loginid:Optional[str] = None
    user_name:Optional[str] = None



   




